package com.onlyphoto.onlymall.widget;


import com.onlyphoto.onlymall.base.BaseDialogFragment;

import java.lang.ref.WeakReference;

/**
 * Created by gaochujia on 2019-09-19.
 */

public class BaseDialogFragmentWrapper {
    private WeakReference<BaseDialogFragment> baseDialogFragment;
    private int priority = 10;                                      // 0-10 ,最高优先级0，10最低。默认10；
    private long timestamp;
    private String tag;
    private boolean forceCloseOther = false;

    public boolean isForceCloseOther() {
        return forceCloseOther;
    }

    public void setForceCloseOther(boolean forceCloseOther) {
        this.forceCloseOther = forceCloseOther;
    }

    public String getTag() {
        return tag;
    }

    public void setTag(String tag) {
        this.tag = tag;
    }


    public BaseDialogFragmentWrapper(BaseDialogFragment baseDialogFragment, String tag, boolean forceCloseOther) {
        this.timestamp = System.currentTimeMillis();
        this.baseDialogFragment = new WeakReference<>(baseDialogFragment);
        this.tag = tag;
        this.forceCloseOther = forceCloseOther;
        if (forceCloseOther) {
            this.priority = -1;
        }
    }

    public BaseDialogFragmentWrapper(BaseDialogFragment baseDialogFragment, int priority, String tag, boolean forceCloseOther) {
        this.baseDialogFragment = new WeakReference<>(baseDialogFragment);
        this.priority = priority;
        this.timestamp = System.currentTimeMillis();
        this.tag = tag;
        this.forceCloseOther = forceCloseOther;
        if (forceCloseOther) {
            this.priority = -1;
        }
    }

    public BaseDialogFragment getBaseDialogFragment() {
        return baseDialogFragment.get();
    }

    public void setBaseDialogFragment(BaseDialogFragment baseDialogFragment) {
        this.baseDialogFragment = new WeakReference<>(baseDialogFragment);
    }

    public int getPriority() {
        return priority;
    }

    public void setPriority(int priority) {
        this.priority = priority;
    }

    public long getTimestamp() {
        return timestamp;
    }

}